package cn.dlc.com.order.feign;

import cn.dlc.com.order.entity.Product;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author 邓立川
 * @date 2021/1/5 17:39
 * @desc 方式2整合sentinel，这个方式如果出现异常可以看到，
 * 注意ProductService中FeignClient注解的使用
 */
@Component
@Slf4j
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {

    @Override
    public ProductService create(Throwable throwable) {
        return new ProductService() {
            @Override
            public Product findById(String id) {
                log.info("{}",throwable);
                Product product = new Product();
                product.setDesc("进入ProductServiceFallbackFactory的容错方法中....");
                return product;
            }
        };
    }
}
